<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="流水号" prop="serial">
        <el-input
          v-model="queryParams.serial"
          placeholder="请输入流水号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="订单号" prop="orderCode">
        <el-input
          v-model="queryParams.orderCode"
          placeholder="请输入订单号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="所属合同" prop="ssContract">
        <el-input
          v-model="queryParams.ssContract"
          placeholder="请输入所属合同"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="订单类型" prop="orderType">
        <el-select v-model="queryParams.orderType" placeholder="请选择订单类型" clearable>
          <el-option
            v-for="dict in dict.type.wms_balance_type"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="流水类型" prop="type">
        <el-select v-model="queryParams.type" placeholder="请选择流水类型" clearable>
          <el-option
            v-for="dict in dict.type.wms_balance_pay_type"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="状态" prop="status">
        <el-select v-model="queryParams.status" placeholder="请选择状态" clearable>
          <el-option
            v-for="dict in dict.type.wms_balance_status"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="最晚支付时间" prop="payTime">
        <el-date-picker clearable
          v-model="queryParams.payTime"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="请选择最晚支付时间">
        </el-date-picker>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="balanceLogList">
      <el-table-column type="index" label="序号" width="55" align="center">
        <template slot-scope="scope">
          {{(queryParams.pageNum - 1) * queryParams.pageSize + scope.$index +1}}
        </template>
      </el-table-column>
      <el-table-column label="流水号" align="center" prop="serial" />
      <el-table-column label="所属合同" align="center" prop="ssContract" :show-overflow-tooltip="true"/>
      <el-table-column label="订单号" align="center" prop="orderCode">
        <template slot-scope="scope">
          <el-link type="primary" @click="handleLook(scope.row)">{{ scope.row.orderCode }}</el-link>
        </template>
      </el-table-column>
      <el-table-column label="订单类型" align="center" prop="orderType">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.wms_balance_type" :value="scope.row.orderType"/>
        </template>
      </el-table-column>
      <el-table-column label="流水类型" align="center" prop="type">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.wms_balance_pay_type" :value="scope.row.type"/>
        </template>
      </el-table-column>
      <el-table-column label="订单金额" align="center" prop="price" />
      <el-table-column label="已支付金额" align="center" prop="payPrice" />
      <el-table-column label="支付完成比例" align="center" prop="payRate" />
      <el-table-column label="状态" align="center" prop="status">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.wms_balance_status" :value="scope.row.status"/>
          <span v-if="scope.row.status === '2'">原因：{{scope.row.error}}</span>
        </template>
      </el-table-column>
      <el-table-column label="创建人" align="center" prop="userStr" />
      <el-table-column label="商品编码" align="center" prop="productCode" :show-overflow-tooltip="true"/>
      <el-table-column label="最晚支付时间" align="center" prop="payTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.payTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-if="scope.row.status === '0'"
            v-hasPermi="['wms:balanceLog:edit']"
          >支付完成</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 支付完成对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="80%" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-row :gutter="10">
          <el-col :span="12">
            <el-form-item label="订单号">
              {{form.orderCode}}
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="订单类型">
              <dict-tag :options="dict.type.wms_balance_type" :value="form.orderType"/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="10">
          <el-col :span="12">
            <el-form-item label="订单金额" prop="price">
              {{form.price}}
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="完成比例">
              {{form.payRate}}
            </el-form-item>
          </el-col>
        </el-row>
        <el-form-item label="支付金额" prop="payPrice">
          <el-input v-model="form.payPrice" placeholder="请输入支付金额" />
        </el-form-item>
        <el-form-item label="支付附件">
          <el-upload
            class="upload-demo"
            :headers="uploadAccessory.headers"
            :action="uploadAccessory.url"
            :on-remove="handlePayRemove"
            :on-success="handlePaySuccess"
            multiple
            accept=".jpg,.png,.jpeg"
            :file-list="fileList">
            <i class="el-icon-upload"></i>
            <div class="el-upload__text">将文件拖到此处，或<em>点击上传</em></div>
            <div class="el-upload__tip text-center" slot="tip">
              <span>仅允许导入jpg/png/pdf格式文件。</span>
            </div>
          </el-upload>
        </el-form-item>
        <h1>商品信息</h1>
        <el-table :data="orderProductTable">
          <el-table-column label="序号" align="center" type="index" width="50"/>
          <el-table-column type="expand">
            <template slot-scope="props">
              <el-form label-position="left" inline class="demo-table-expand">
                <el-row :gutter="10">
                  <el-col :span="12">
                    <el-form-item label="商品编码">
                      <span>{{ props.row.productCode }}</span>
                    </el-form-item>
                  </el-col>
                  <el-col :span="12">
                    <el-form-item label="商品类型">
                      <span>{{ props.row.productTypeName }}</span>
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row :gutter="10">
                  <el-col :span="12">
                    <el-form-item label="计数单位">
                      <span>{{ props.row.unitName }}</span>
                    </el-form-item>
                  </el-col>
                  <el-col :span="12">
                    <el-form-item label="尺寸单位">
                      <span>{{ props.row.ccUnitName }}</span>
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row :gutter="10">
                  <el-col :span="12">
                    <el-form-item label="尺寸">
                      <span v-if="props.row.longWith || props.row.weight || props.row.height">{{ props.row.longWith + '*' + props.row.weight + '*' + props.row.height }}</span>
                    </el-form-item>
                  </el-col>
                  <el-col :span="12">
                    <el-form-item label="重量">
                      <span>{{ props.row.zl }}</span>
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row :gutter="10">
                  <el-col :span="12">
                    <el-form-item label="交货期（厂家）">
                      <span>{{ props.row.manufacturerDelivery }}</span>
                    </el-form-item>
                  </el-col>
                  <el-col :span="12">
                    <el-form-item label="交货期（买家）">
                      <span>{{ props.row.delivery }}</span>
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-form-item label="详情">
                  <span>{{ props.row.detail }}</span>
                </el-form-item>
              </el-form>
            </template>
          </el-table-column>
          <el-table-column label="商品名称" align="center" prop="productName" :show-overflow-tooltip="true"/>
          <el-table-column label="商品型号" align="center" prop="modal" :show-overflow-tooltip="true"/>
          <el-table-column label="商品数量" align="center" prop="productNum"/>
          <el-table-column label="生产厂家" align="center" prop="scPurchaseCompanyName"/>
          <el-table-column label="成本" align="center" prop="oldOnlyPrice"/>
          <el-table-column label="单价" align="center" prop="onlyPrice"/>
          <el-table-column label="总价" align="center" prop="allPrice"/>
        </el-table>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm" v-loading="btnLoading">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>

    <!-- 详情对话框 -->
    <el-dialog title="订单详情（合同）" custom-class="bjDetail" :visible.sync="openContractLook" width="80%" append-to-body>
      <el-form>
        <el-row :gutter="10">
          <el-col :span="12">
            <el-form-item label="合同金额">
              {{contractInfo.contractPrice}}
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="内容数量">
              {{contractInfo.productNum}}
            </el-form-item>
          </el-col>
        </el-row>
        <el-form-item label="付款方式">
          <dict-tag :options="dict.type.wms_pay_type" :value="contractInfo.payType"/>
        </el-form-item>
        <el-row :gutter="10">
          <el-col :span="12">
            <el-form-item label="是否物流">
              <dict-tag :options="dict.type.sys_yes_no" :value="contractInfo.ifLogistics"/>
            </el-form-item>
          </el-col>
          <el-col :span="12" v-if="contractInfo.ifLogistics === 'Y'">
            <el-form-item label="物流方式">
              <dict-tag :options="dict.type.wms_logistics" :value="contractInfo.logisticsModule"/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="10" v-if="contractInfo.payType === '1'">
          <el-col :span="12">
            <el-form-item label="先款比例">
              {{contractInfo.prefixPayRate}}
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="进度款比例">
              {{contractInfo.processPayRate}}
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="10" v-if="contractInfo.payType === '1'">
          <el-col :span="12">
            <el-form-item label="尾款比例">
              {{contractInfo.tailPayRate}}
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="尾款支付时间">
              货到后{{contractInfo.tailPayTime}}天付款
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="10">
          <el-col :span="12">
            <el-form-item label="支付金额">
              {{contractInfo.payPrice}}
            </el-form-item>
          </el-col>
        </el-row>

        <el-form-item label="合同附件" v-if="contractInfo.fileList.length > 0">
          <el-upload
            action=""
            class="upload-demo"
            :disabled="true"
            :on-preview="handlePreview"
            :file-list="contractInfo.fileList">
          </el-upload>
        </el-form-item>

        <el-form-item label="支付附件" v-if="contractInfo.payFileList.length > 0">
          <el-upload
            action=""
            class="upload-demo"
            :disabled="true"
            :on-preview="handlePreview"
            :file-list="contractInfo.payFileList">
          </el-upload>
        </el-form-item>
      </el-form>
      <h1>商品信息</h1>
      <el-table :data="contractInfo.orderProductTable">
        <el-table-column label="序号" align="center" type="index" width="50"/>
        <el-table-column type="expand">
          <template slot-scope="props">
            <el-form label-position="left" inline class="demo-table-expand">
              <el-row :gutter="10">
                <el-col :span="12">
                  <el-form-item label="商品编码">
                    <span>{{ props.row.productCode }}</span>
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item label="商品类型">
                    <span>{{ props.row.productTypeName }}</span>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row :gutter="10">
                <el-col :span="12">
                  <el-form-item label="计数单位">
                    <span>{{ props.row.unitName }}</span>
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item label="尺寸单位">
                    <span>{{ props.row.ccUnitName }}</span>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row :gutter="10">
                <el-col :span="12">
                  <el-form-item label="尺寸">
                    <span v-if="props.row.longWith || props.row.weight || props.row.height">{{ props.row.longWith + '*' + props.row.weight + '*' + props.row.height }}</span>
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item label="重量">
                    <span>{{ props.row.zl }}</span>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row :gutter="10">
                <el-col :span="12">
                  <el-form-item label="交货期（厂家）">
                    <span>{{ props.row.manufacturerDelivery }}</span>
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item label="交货期（买家）">
                    <span>{{ props.row.delivery }}</span>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-form-item label="详情">
                <span>{{ props.row.detail }}</span>
              </el-form-item>
            </el-form>
          </template>
        </el-table-column>
        <el-table-column label="商品名称" align="center" prop="productName" :show-overflow-tooltip="true"/>
        <el-table-column label="生产厂家" align="center" prop="scPurchaseCompanyName" :show-overflow-tooltip="true"/>
        <el-table-column label="商品数量" align="center" prop="productNum"/>
        <el-table-column label="成本" align="center" prop="oldOnlyPrice"/>
        <el-table-column label="单价" align="center" prop="onlyPrice"/>
        <el-table-column label="总价" align="center" prop="allPrice"/>
      </el-table>
    </el-dialog>

    <!-- 详情对话框 -->
    <el-dialog title="订单详情（采购单）" custom-class="bjDetail" :visible.sync="openPurchaseLook" width="80%" append-to-body>
      <el-form>
        <el-row :gutter="10">
          <el-col :span="12">
            <el-form-item label="采购金额">
              {{purchaseInfo.purchasePrice}}
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="内容数量">
              {{purchaseInfo.productNum}}
            </el-form-item>
          </el-col>
        </el-row>
        <el-form-item label="付款方式">
          <dict-tag :options="dict.type.wms_pay_type" :value="purchaseInfo.payType"/>
        </el-form-item>
        <el-row :gutter="10" v-if="purchaseInfo.payType === '1'">
          <el-col :span="12">
            <el-form-item label="先款比例">
              {{purchaseInfo.prefixPayRate}}
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="进度款比例">
              {{purchaseInfo.processPayRate}}
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="10" v-if="purchaseInfo.payType === '1'">
          <el-col :span="12">
            <el-form-item label="尾款比例">
              {{purchaseInfo.tailPayRate}}
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="尾款支付时间">
              货到后{{purchaseInfo.tailPayTime}}天付款
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="10">
          <el-col :span="12">
            <el-form-item label="支付金额">
              {{purchaseInfo.payPrice}}
            </el-form-item>
          </el-col>
        </el-row>

        <el-form-item label="合同附件" v-if="purchaseInfo.fileList.length > 0">
          <el-upload
            action=""
            class="upload-demo"
            :disabled="true"
            :on-preview="handlePreview"
            :file-list="purchaseInfo.fileList">
          </el-upload>
        </el-form-item>

        <el-form-item label="支付附件" v-if="purchaseInfo.payFileList.length > 0">
          <el-upload
            action=""
            class="upload-demo"
            :disabled="true"
            :on-preview="handlePreview"
            :file-list="purchaseInfo.payFileList">
          </el-upload>
        </el-form-item>
      </el-form>
      <h1>商品信息</h1>
      <el-table :data="purchaseInfo.orderProductTable">
        <el-table-column label="序号" align="center" type="index" width="50"/>
        <el-table-column type="expand">
          <template slot-scope="props">
            <el-form label-position="left" inline class="demo-table-expand">
              <el-row :gutter="10">
                <el-col :span="12">
                  <el-form-item label="商品编码">
                    <span>{{ props.row.productCode }}</span>
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item label="商品类型">
                    <span>{{ props.row.productTypeName }}</span>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row :gutter="10">
                <el-col :span="12">
                  <el-form-item label="计数单位">
                    <span>{{ props.row.unitName }}</span>
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item label="尺寸单位">
                    <span>{{ props.row.ccUnitName }}</span>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row :gutter="10">
                <el-col :span="12">
                  <el-form-item label="尺寸">
                    <span v-if="props.row.longWith || props.row.weight || props.row.height">{{ props.row.longWith + '*' + props.row.weight + '*' + props.row.height }}</span>
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item label="重量">
                    <span>{{ props.row.zl }}</span>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row :gutter="10">
                <el-col :span="12">
                  <el-form-item label="交货期（厂家）">
                    <span>{{ props.row.manufacturerDelivery }}</span>
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item label="交货期（买家）">
                    <span>{{ props.row.delivery }}</span>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-form-item label="详情">
                <span>{{ props.row.detail }}</span>
              </el-form-item>
            </el-form>
          </template>
        </el-table-column>
        <el-table-column label="商品名称" align="center" prop="productName" :show-overflow-tooltip="true"/>
        <el-table-column label="商品型号" align="center" prop="modal" :show-overflow-tooltip="true"/>
        <el-table-column label="生产厂家" align="center" prop="scPurchaseCompanyName" :show-overflow-tooltip="true"/>
        <el-table-column label="商品数量" align="center" prop="productNum"/>
        <el-table-column label="成本" align="center" prop="oldOnlyPrice"/>
        <el-table-column label="单价" align="center" prop="onlyPrice"/>
        <el-table-column label="总价" align="center" prop="allPrice"/>
      </el-table>
    </el-dialog>

    <!-- 详情对话框 -->
    <el-dialog title="订单详情（物流单）" custom-class="bjDetail" :visible.sync="openLogisticsLook" width="80%" append-to-body>
      <el-form>
        <el-row :gutter="10">
          <el-col :span="12">
            <el-form-item label="运费金额">
              {{logisticsInfo.logisticsPrice}}
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="内容数量">
              {{logisticsInfo.productNum}}
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="10">
          <el-col :span="12">
            <el-form-item label="物流方式">
              <dict-tag :options="dict.type.wms_logistics" :value="logisticsInfo.payType"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="物流条款">
              {{logisticsInfo.logisticsTerms}}
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="10">
          <el-col :span="12">
            <el-form-item label="收货人">
              {{logisticsInfo.consigneeIdStr}}
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="货运单号">
              {{logisticsInfo.logisticsNo}}
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="10">
          <el-col :span="12">
            <el-form-item label="发货城市">
              {{logisticsInfo.sendName}}
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="发货地址">
              {{logisticsInfo.sendAddress}}
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="10">
          <el-col :span="12">
            <el-form-item label="收货城市">
              {{logisticsInfo.deliveryName}}
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="收货地址">
              {{logisticsInfo.deliveryAddress}}
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="10">
          <el-col :span="12">
            <el-form-item label="箱体编号">
              {{logisticsInfo.boxCode}}
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="预计到货日期">
              {{logisticsInfo.goodsArrivedTime}}
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="10">
          <el-col :span="12">
            <el-form-item label="清关公司">
              {{logisticsInfo.qgEntName}}
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="付款方式">
              <dict-tag :options="dict.type.wms_pay_type" :value="logisticsInfo.payType"/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="10" v-if="logisticsInfo.payType === '1'">
          <el-col :span="12">
            <el-form-item label="先款比例">
              {{logisticsInfo.prefixPayRate}}
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="进度款比例">
              {{logisticsInfo.processPayRate}}
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="10" v-if="logisticsInfo.payType === '1'">
          <el-col :span="12">
            <el-form-item label="尾款比例">
              {{logisticsInfo.tailPayRate}}
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="尾款支付时间">
              货到后{{logisticsInfo.tailPayTime}}天付款
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="10">
          <el-col :span="12">
            <el-form-item label="支付金额">
              {{logisticsInfo.payPrice}}
            </el-form-item>
          </el-col>
        </el-row>

        <el-form-item label="箱体照片" v-if="logisticsInfo.fileList.length > 0">
          <el-upload
            action=""
            class="upload-demo"
            :disabled="true"
            :on-preview="handlePreview"
            list-type="picture"
            :file-list="logisticsInfo.fileList">
          </el-upload>
        </el-form-item>

        <el-form-item label="合同附件" v-if="logisticsInfo.contractFileList.length > 0">
          <el-upload
            action=""
            class="upload-demo"
            :disabled="true"
            :on-preview="handlePreview"
            :file-list="logisticsInfo.contractFileList">
          </el-upload>
        </el-form-item>

        <el-form-item label="支付附件" v-if="logisticsInfo.payFileList.length > 0">
          <el-upload
            action=""
            class="upload-demo"
            :disabled="true"
            :on-preview="handlePreview"
            :file-list="logisticsInfo.payFileList">
          </el-upload>
        </el-form-item>
      </el-form>
      <h1>商品信息</h1>
      <el-table :data="logisticsInfo.orderProductTable">
        <el-table-column label="序号" align="center" type="index" width="50"/>
        <el-table-column type="expand">
          <template slot-scope="props">
            <el-form label-position="left" inline class="demo-table-expand">
              <el-row :gutter="10">
                <el-col :span="12">
                  <el-form-item label="商品编码">
                    <span>{{ props.row.productCode }}</span>
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item label="商品类型">
                    <span>{{ props.row.productTypeName }}</span>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row :gutter="10">
                <el-col :span="12">
                  <el-form-item label="计数单位">
                    <span>{{ props.row.unitName }}</span>
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item label="尺寸单位">
                    <span>{{ props.row.ccUnitName }}</span>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row :gutter="10">
                <el-col :span="12">
                  <el-form-item label="尺寸">
                    <span v-if="props.row.longWith || props.row.weight || props.row.height">{{ props.row.longWith + '*' + props.row.weight + '*' + props.row.height }}</span>
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item label="重量">
                    <span>{{ props.row.zl }}</span>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-form-item label="详情">
                <span>{{ props.row.detail }}</span>
              </el-form-item>
            </el-form>
          </template>
        </el-table-column>
        <el-table-column label="商品名称" align="center" prop="productName" :show-overflow-tooltip="true"/>
        <el-table-column label="商品型号" align="center" prop="modal" :show-overflow-tooltip="true"/>
        <el-table-column label="生产厂家" align="center" prop="scPurchaseCompanyName" :show-overflow-tooltip="true"/>
        <el-table-column label="交货期（买家）" align="center" prop="delivery"/>
        <el-table-column label="商品数量" align="center" prop="productNum"/>
        <el-table-column label="成本" align="center" prop="oldOnlyPrice"/>
        <el-table-column label="单价" align="center" prop="onlyPrice"/>
        <el-table-column label="总价" align="center" prop="allPrice"/>
      </el-table>
    </el-dialog>
  </div>
</template>

<script>
import { listBalanceLog, updateBalanceLog } from "@/api/wms/balanceLog";
import {getToken} from "@/utils/auth";
import {getContractAuditInfo, getLogisticsAuditInfo, getPurchaseAuditInfo} from "@/api/wms/auditOrder";
import {getOrderProduct} from "@/api/wms/inquireOrder";

export default {
  name: "BalanceLog",
  dicts: ['wms_balance_type','wms_balance_status','wms_balance_pay_type','wms_pay_type','sys_yes_no','wms_logistics'],
  data() {
    return {
      prefix: process.env.VUE_APP_BASE_API,
      // 附件参数
      uploadAccessory: {
        // 设置上传的请求头部
        headers: { Authorization: "Bearer " + getToken() },
        // 上传的地址
        url: process.env.VUE_APP_BASE_API + "/wms/balanceLog/uploadPic"
      },
      //按钮加载
      btnLoading: false,
      // 遮罩层
      loading: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 资金管理表格数据
      balanceLogList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 合同显示弹出层
      openContractLook: false,
      // 采购单显示弹出层
      openPurchaseLook: false,
      // 物流单显示弹出层
      openLogisticsLook: false,
      orderProductTable: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        serial: null,
        orderCode: null,
        orderType: null,
        type: null,
        status: null,
        payTime: null,
        ssContract: null
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        payPrice: [
          { required: true, message: "支付金额不可为空", trigger: "blur" },
          { pattern: /^(0|[1-9])\d{0,8}(\.\d{1,2})?$/, message: '支付金额只能是数值最大9位整数2位小数', trigger: 'blur' }
        ],
      },
      // 支付附件
      accessoryList: [],
      // 支付附件显示
      fileList: [],
      contractInfo:{
        productNum: null,
        logisticsModule: '',
        ifLogistics: '',
        payType: '',
        contractPrice: '',
        prefixPayRate: '',
        processPayRate: '',
        tailPayRate: '',
        tailPayTime: '',
        payPrice: '',
        orderProductTable:[],
        fileList:[],
        payFileList:[],
      },
      purchaseInfo:{
        productNum: null,
        payType: '',
        purchasePrice: '',
        prefixPayRate: '',
        processPayRate: '',
        tailPayRate: '',
        tailPayTime: '',
        payPrice: '',
        orderProductTable:[],
        fileList:[],
        payFileList:[],
      },
      logisticsInfo:{
        productNum: null,
        payType: '',
        logisticsPrice: '',
        prefixPayRate: '',
        processPayRate: '',
        tailPayRate: '',
        tailPayTime: '',
        boxCode: '',
        logisticsNo: null,
        logisticsModule: null,
        goodsArrivedTime: null,
        consigneeIdStr: null,
        sendAddress: null,
        sendName: null,
        deliveryAddress: null,
        deliveryName: null,
        logisticsTerms: null,
        qgEntName: null,
        payPrice: null,
        orderProductTable:[],
        fileList:[],
        payFileList:[],
        contractFileList:[],
      },
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询资金管理列表 */
    getList() {
      this.loading = true;
      listBalanceLog(this.queryParams).then(response => {
        this.balanceLogList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        serial: null,
        orderCode: null,
        orderType: null,
        price: null,
        payPrice: null,
        payRate: null
      };
      this.resetForm("form");
    },
    resetLook(){
      this.contractInfo = {
        productNum: null,
        logisticsModule: '',
        ifLogistics: '',
        payType: '',
        contractPrice: '',
        prefixPayRate: '',
        processPayRate: '',
        tailPayRate: '',
        tailPayTime: '',
        payPrice: '',
        orderProductTable:[],
        fileList:[],
        payFileList:[],
      }
      this.purchaseInfo = {
        productNum: null,
        payType: '',
        purchasePrice: '',
        prefixPayRate: '',
        processPayRate: '',
        tailPayRate: '',
        tailPayTime: '',
        payPrice: '',
        orderProductTable:[],
        fileList:[],
        payFileList:[],
      }
      this.logisticsInfo = {
        productNum: null,
        payType: '',
        logisticsPrice: '',
        prefixPayRate: '',
        processPayRate: '',
        tailPayRate: '',
        tailPayTime: '',
        boxCode: '',
        logisticsNo: null,
        logisticsModule: null,
        goodsArrivedTime: null,
        consigneeIdStr: null,
        sendAddress: null,
        sendName: null,
        deliveryAddress: null,
        deliveryName: null,
        logisticsTerms: null,
        qgEntName: null,
        payPrice: null,
        orderProductTable:[],
        fileList:[],
        payFileList:[],
        contractFileList:[],
      }
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    /** 支付完成按钮操作 */
    handleUpdate(row) {
      this.reset();
      this.form.orderCode = row.orderCode;
      this.form.orderType = row.orderType;
      this.form.price = row.price;
      this.orderProductTable = []
      getOrderProduct({orderCode: row.orderCode}).then(response => {
        this.orderProductTable = response.data

        this.form.payRate = this.orderProductTable.length;
        this.open = true;
        this.title = "支付完成";
      })
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.accessoryList.length > 0) {
            this.btnLoading = true
            this.form.accessoryList = this.accessoryList
            updateBalanceLog(this.form).then(response => {
              this.$modal.msgSuccess("提交成功，等待审核");
              this.open = false;
              this.getList();
            }).finally(f => {
              this.btnLoading = false
            });
          } else {
            this.$modal.msgError("支付附件不可为空！");
          }
        }
      });
    },
    // 支付附件删除
    handlePayRemove(file, fileList) {
      this.accessoryList.splice(this.accessoryList.indexOf(file.url), 1);
    },
    // 支付附件上传成功处理
    handlePaySuccess(response, file, fileList) {
      if (response.code == 200) {
        this.accessoryList.push(response.imgUrl)
      }
    },
    // 查看物流商品
    handleLook(row){
      this.resetLook()
      switch (row.orderType){
        case "0":
          getContractAuditInfo({orderCode: row.orderCode}).then(response => {
            let data = response.data;
            this.contractInfo.logisticsModule = data.logisticsModule
            this.contractInfo.ifLogistics = data.ifLogistics
            this.contractInfo.payType = data.payType
            this.contractInfo.contractPrice = data.contractPrice
            this.contractInfo.prefixPayRate = data.prefixPayRate
            this.contractInfo.processPayRate = data.processPayRate
            this.contractInfo.tailPayRate = data.tailPayRate
            this.contractInfo.tailPayTime = data.tailPayTime
            this.contractInfo.productNum = data.productNum
            this.contractInfo.payPrice = data.payPrice
            this.contractInfo.orderProductTable = data.products
            let accessoryList = data.accessoryList
            let payAccessoryList = data.payAccessoryList

            if (accessoryList && accessoryList.length > 0) {
              accessoryList.forEach(item => {
                let urls = item.split("/")
                this.contractInfo.fileList.push({name: urls[urls.length - 1], url: this.prefix + item})
              })
            }
            if (payAccessoryList && payAccessoryList.length > 0) {
              payAccessoryList.forEach(item => {
                let urls = item.split("/")
                this.contractInfo.payFileList.push({name: urls[urls.length - 1], url: this.prefix + item})
              })
            }
            this.openContractLook = true
          })
          break
        case "1":
          // 采购单
          getPurchaseAuditInfo({orderCode: row.orderCode}).then(response => {
            let data = response.data;
            this.purchaseInfo.payType = data.payType
            this.purchaseInfo.purchasePrice = data.purchasePrice
            this.purchaseInfo.prefixPayRate = data.prefixPayRate
            this.purchaseInfo.processPayRate = data.processPayRate
            this.purchaseInfo.tailPayRate = data.tailPayRate
            this.purchaseInfo.tailPayTime = data.tailPayTime
            this.purchaseInfo.payPrice = data.payPrice
            this.purchaseInfo.productNum = data.productNum
            this.purchaseInfo.orderProductTable = data.products
            let accessoryList = data.accessoryList
            let payAccessoryList = data.payAccessoryList

            if (accessoryList && accessoryList.length > 0) {
              accessoryList.forEach(item => {
                let urls = item.split("/")
                this.purchaseInfo.fileList.push({name: urls[urls.length - 1], url: this.prefix + item})
              })
            }
            if (payAccessoryList && payAccessoryList.length > 0) {
              payAccessoryList.forEach(item => {
                let urls = item.split("/")
                this.purchaseInfo.payFileList.push({name: urls[urls.length - 1], url: this.prefix + item})
              })
            }
            this.openPurchaseLook = true
          })
          break
        case "2":
          getLogisticsAuditInfo({orderCode: orderCode}).then(response => {
            let data = response.data;
            this.logisticsInfo.productNum = data.productNum
            this.logisticsInfo.payType = data.payType
            this.logisticsInfo.logisticsPrice = data.logisticsPrice
            this.logisticsInfo.purchasePrice = data.purchasePrice
            this.logisticsInfo.prefixPayRate = data.prefixPayRate
            this.logisticsInfo.processPayRate = data.processPayRate
            this.logisticsInfo.tailPayRate = data.tailPayRate
            this.logisticsInfo.tailPayTime = data.tailPayTime
            this.logisticsInfo.boxCode = data.boxCode
            this.logisticsInfo.logisticsNo = data.logisticsNo
            this.logisticsInfo.goodsArrivedTime = data.goodsArrivedTime
            this.logisticsInfo.logisticsModule = data.logisticsModule
            this.logisticsInfo.sendName = data.sendName
            this.logisticsInfo.sendAddress = data.sendAddress
            this.logisticsInfo.deliveryAddress = data.deliveryAddress
            this.logisticsInfo.deliveryName = data.deliveryName
            this.logisticsInfo.logisticsTerms = data.logisticsTerms
            this.logisticsInfo.qgEntName = data.qgEntName
            this.logisticsInfo.consigneeIdStr = data.consigneeStr
            this.logisticsInfo.payPrice = data.payPrice

            this.logisticsInfo.orderProductTable = data.products
            let accessoryList = data.accessoryList
            let payAccessoryList = data.payAccessoryList
            let contractAccessoryList = data.contractAccessoryList

            if (accessoryList && accessoryList.length > 0) {
              accessoryList.forEach(item => {
                let urls = item.split("/")
                this.logisticsInfo.fileList.push({name: urls[urls.length - 1], url: this.prefix + item})
              })
            }
            if (payAccessoryList && payAccessoryList.length > 0) {
              payAccessoryList.forEach(item => {
                let urls = item.split("/")
                this.logisticsInfo.payFileList.push({name: urls[urls.length - 1], url: this.prefix + item})
              })
            }
            if (contractAccessoryList && contractAccessoryList.length > 0) {
              contractAccessoryList.forEach(item => {
                let urls = item.split("/")
                this.logisticsInfo.contractFileList.push({name: urls[urls.length - 1], url: this.prefix + item})
              })
            }
            this.openLogisticsLook = true
          })
          break
      }
    },
    // 文件点击事件
    handlePreview(file){
      window.open(file.url,'_blank');
    },
  }
};
</script>
